<app-content-header
  [search]="search"
  [action]="aclService.canAbility('api.post.camel.order.one') && action"
  (actionClick)="goAdd()">
</app-content-header>

<div class="cil-table-block">
  <st
    #st
    [scroll]="scroll"
    [data]="data"
    [columns]="columns"
    [widthMode]="widthMode"
    [ps]="ps"
    [pi]="pi"
    [page]="stPage"
    [total]="total"
    [loading]="loading"
    (change)="onChange($event)"
  >
  <ng-template st-row="amount" let-item>
    <span>{{ item.amount | amtFormat:item.currency | async}}</span>
  </ng-template>
  <ng-template st-row="status" let-item>
    <span>{{ getTradeStatus(item.status) }}</span>
  </ng-template>
  </st>
</div>

<ng-template #search>
  <app-search [(data)]="searchSchema" (bindSearch)="handleSearch()"></app-search>
</ng-template>

<ng-template #action>
  <i nz-icon type="plus"></i> {{ 'BTN.ADD' | translate }}
</ng-template>

<ng-template #transAmt>
  <nz-input-group>
    <div nz-col nzSpan="10">
      <nz-input-number 
        [style.width]="'100%'"  
        [ngModel]="transAmtFrom" 
        (ngModelChange)="transAmtFrom=$event;validateTransAmt()" 
        [nzMin]="0" 
        [nzPrecision]='0'>
      </nz-input-number>
    </div>
    <div nz-col nzSpan="4" class="cil__trans-amt-split">
      <div>——</div>
    </div>
    <div nz-col nzSpan="10">
      <nz-input-number 
        [style.width]="'100%'"  
        [ngModel]="transAmtTo" 
        (ngModelChange)="transAmtTo=$event;validateTransAmt()" 
        [nzMin]="0" 
        [nzPrecision]='0'>
      </nz-input-number>
    </div>
  </nz-input-group>
</ng-template>

<ng-template #tplCurrency>
  <app-currency-select [insCode]="insCode" [(ngModel)]="selectedCurrency"></app-currency-select>
</ng-template>

<ng-template #insTpl>
  <app-aams-select
    level="institution"
    [(ngModel)]="selectedAcquirer"
    [disabled]="isAcquirerUser"
    (valueChange)="aamsChangeHandler($event)"
  ></app-aams-select>
</ng-template>

<ng-template #agentTpl>
  <app-aams-select
    level="agent"
    [insCode]="selectedAcquirer ? selectedAcquirer.code : ''"
    [(ngModel)]="selectedGroup"
    [disabled]="isAgentUser"
    (valueChange)="aamsChangeHandler($event)"
  ></app-aams-select>
</ng-template>

<ng-template #merchantTpl>
  <app-aams-select
    level="merchant"
    [insCode]="selectedAcquirer ? selectedAcquirer.code : ''"
    [agentCode]="selectedGroup ? selectedGroup.code : ''"
    [(ngModel)]="selectedMerchant"
    [disabled]="isMerchantUser"
    (valueChange)="aamsChangeHandler($event)"
  ></app-aams-select>
</ng-template>

<ng-template #storeTpl>
  <app-aams-select
    level="store"
    [insCode]="selectedAcquirer ? selectedAcquirer.code : ''"
    [agentCode]="selectedGroup ? selectedGroup.code : ''"
    [intMerCode]="selectedMerchant ? selectedMerchant.code : ''"
    [(ngModel)]="selectedStore"
    [disabled]="isStoreUser"
    (valueChange)="aamsChangeHandler($event)"
  ></app-aams-select>
</ng-template>